<template>
  <!-- 选择身份 -->

  <view class="identity" :class="{ popupShow: zujianxianshi }">
    <view class="title"> 请选择您的身份 </view>
    <view class="jobSeeker" @click="submit(1)">
      <image class="img" src="/static/image/my/qzz.png" mode=""></image>
      <view class="text"> 我是求职者 </view>
    </view>
    <view class="employer" @click="submit(2)">
      <image class="img1" src="/static/image/my/zpz.png" mode=""></image>
      <view class="text">
        <view>我是招聘者</view>
      </view>
    </view>

    <u-popup :show="zujianxianshi" mode="bottom" round="10" @close="clicklist1">
      <view class="upopup">
        <view class="upopuptop">选择企业</view>
        <view class="upopupnr" v-if="promptDatalist.length > 0">
          <view
            class="upopupnrtext"
            v-for="(item, key) in promptDatalist"
            @click="clicklist(item)"
            :key="key"
          >
            <image :src="URL + item.LogoPath" class="imgestext"></image>
            <text class="nartext">{{ item.FullName }}</text>
            <!-- <text v-show="item.Status==1" class="status1">已认证</text>
						<text v-show="item.Status==0" class="status2">未认证</text> -->
            <image
              v-show="item.Status == 1"
              src="/static/recruit/index/yrz.png"
              class="imgrz"
            ></image>
            <image
              v-show="item.Status == 0"
              src="/static/recruit/index/rzz.png"
              class="imgrz"
            ></image>
            <image
              v-show="item.Status == 2"
              src="/static/recruit/index/rzsb.png"
              class="imgrz"
            ></image>
          </view>
        </view>
        <view class="upopupnr" v-else>
          <view
            class="upopupnrtext1"
            style="text-align: left; font-size: 32rpx; padding-top: 30rpx"
          >
            <text class="nartext"
              >当前账号还没有绑定企业，需要创建企业才能发布职位~</text
            >
          </view>
        </view>

        <view class="but">
          <view @click="clicklist('add')" class="upopupnrbut"
            >{{ promptDatalist.length > 0 ? "创建新企业" : "创建企业" }}
          </view>
        </view>
      </view>
    </u-popup>

    <u-popup
      :show="shimingrenzheng"
      mode="bottom"
      round="10"
      @close="clicklist1"
    >
      <view class="upopup">
        <view class="upopuptop">提示</view>

        <view class="upopupnr">
          <view
            class="upopupnrtext1"
            style="text-align: left; font-size: 32rpx; padding-top: 30rpx"
          >
            <text class="nartext"
              >创建企业之前需要进行个人认证，快去认证吧~</text
            >
          </view>
        </view>

        <view class="but">
          <view @click="clickrenzheng" class="upopupnrbut">去认证</view>
        </view>
      </view>
    </u-popup>
  </view>
</template>

<script>
import { nextTick } from "vue";

export default {
  data() {
    return {
      zujianxianshi: false, //弹框显示
      promptDatalist: [], //企业数据
      URL: this.$config.domain.staticUrl,
      shimingrenzheng: false, //弹出实名认证提示框
    };
  },
  onShow() {},
  methods: {
    submit(item) {
      let list = uni.getStorageSync("homelist");
      let user = list.UserInfo.UserId;
      if (item == 1) {
        this.qihuanjushe({
          CurrentRole: 0,
          CurrentCorpId: null,
        });
        uni.setStorageSync("guidePage", user);
      } else {
        this.zujianxianshi = true;
        this.$util.currentUser().then((res) => {
          list = uni.getStorageSync("homelist");
          uni.setStorageSync("guidePage", user);
          if (list.CorpList.length > 0) {
            this.promptDatalist = list.CorpList;
          }
        });
      }
    },
    clicklist1() {
      this.zujianxianshi = false;
    },
    clickrenzheng() {
      let app = getApp();
      if (
        app.globalData.user.Status === 0 ||
        app.globalData.user.Status === 2
      ) {
        uni.navigateTo({
          url:
            "/pages/views/packageB/type-jobhunting/jibenshezhi/jibenziliao/shimingjieguo?status=" +
            app.globalData.user.Status,
        });
      } else {
        uni.navigateTo({
          url: "/pages/views/packageB/type-jobhunting/jibenshezhi/jibenziliao/shimingrenzheng",
        });
      }

      this.shimingrenzheng = false;
    },
    clicklist(e) {
      let User = uni.getStorageSync("homelist");
      // this.zujianxianshi=false
      if (e == "add") {
        if (
          User.UserInfo.Status === null ||
          User.UserInfo.Status === 0 ||
          User.UserInfo.Status === 2
        ) {
          this.zujianxianshi = false;
          this.shimingrenzheng = true;
          // uni.navigateTo({
          // 	url: '/pages/views/packageB/type-jobhunting/jibenshezhi/jibenziliao/shimingrenzheng'
          // })
        } else {
          uni.navigateTo({
            url: "/pages/views/packageB/type-recruit/jibenshezhi/renzhen/qiyei_renzheng",
          });
          this.zujianxianshi = false;
        }
      } else if (e.Status === 0 || e.Status === 2) {
        uni.navigateTo({
          // url: '/pages/views/packageB/type-recruit/jibenshezhi/renzhen/qiyei_renzheng?ids=' + e.Id
          url: `/pages/views/packageB/type-recruit/jibenshezhi/renzhen/qiyei_renzheng?ids=${e.Id}&type=3`,
        });
        this.zujianxianshi = false;
      } else {
        let obj = {
          CurrentRole: 1,
          CurrentCorpId: e.Id,
        };

        this.qihuanjushe(obj);
        this.zujianxianshi = false;
      }
    },

    // 切换身份
    qihuanjushe(obj) {
      // 当前角色 0求职者 1招聘者
      this.$http.core.changCurrentRole(obj).then(async (res) => {
        if (res.Success) {
          //tim退出登录
          await this.$util.timlogout();
          //获取登录信息
          this.$util.currentUser().then(() => {
            this.$util.setCustomTabbar();
            uni.reLaunch({
              url: "/pages/entry/index",
            });
          });
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.identity {
  // width: 100vh;
  height: 100vh;
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
  padding: 0 50rpx;
  background-image: url("/static/image/my/loginbg.png");
  background-repeat: no-repeat;
  background-size: cover;

  .title {
    font-size: 46rpx;
    font-family: PingFang SC-Bold, PingFang SC;
    font-weight: bold;
    color: #151724;
    margin-top: 212rpx;
  }

  .jobSeeker {
    margin-top: 195rpx;
    border-radius: 23rpx;
    opacity: 1;
    border: 1rpx solid #ffadbc;
    height: 160rpx;
    background: #ffffff;
    opacity: 1;
    display: flex;
    justify-content: space-around;
    align-items: center;

    .img {
      width: 240rpx;
      height: 248rpx;
      // margin-left: 30rpx;
      left: 0;
      top: -44rpx;
    }

    .text {
      display: flex;
      justify-content: center;
      align-items: center;
      // margin-left: 136rpx;
      border-radius: 23rpx;
      border: 1rpx solid #ffadbc;
      background: #ff5574;
      border-radius: 43rpx;
      opacity: 1;
      width: 228rpx;
      height: 72rpx;
      font-size: 30rpx;
      font-weight: 400;
      color: #ffffff;
    }
  }

  .employer {
    margin-top: 128rpx;
    height: 160rpx;
    border-radius: 23rpx;
    opacity: 1;
    border: 1rpx solid #84afff;
    display: flex;
    justify-content: space-around;
    align-items: center;

    image {
      width: 240rpx;
      height: 248rpx;
      // margin-left: 30rpx;
      left: 0;
      top: -44rpx;
    }

    .text {
      width: 228rpx;
      height: 72rpx;
      background: #3476fe;
      border-radius: 43rpx;
      opacity: 1;
      font-size: 30rpx;
      font-weight: 400;
      color: #ffffff;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
}

.upopup {
  padding: 20rpx 50rpx;
  // width: 90%;
  text-align: center;

  .upopuptop {
    padding: 20rpx;
    font-size: 36rpx;
  }

  .upopupnr {
    margin: 30rpx 0rpx;
    height: 300rpx;
    overflow-y: auto;

    .upopupnrtext {
      padding: 10rpx 40rpx;
      display: flex;
      justify-content: inherit;
      align-items: center;

      .imgestext {
        width: 40rpx;
        height: 40rpx;
      }

      .nartext {
        padding: 10rpx 20rpx;
        font-size: 30rpx;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        width: 64%;
        text-align: left;
      }

      .status1 {
        color: #165dff;
        border-radius: 10rpx;
        padding: 5rpx 20rpx;
        font-size: 24rpx;
        background-color: #f2f2f2;
      }

      .status2 {
        color: #00000085;
        border-radius: 10rpx;
        padding: 5rpx 20rpx;
        font-size: 24rpx;
        background-color: #f2f2f2;
      }

      .imgrz {
        width: 135rpx;
        height: 40rpx;
      }
    }
  }

  .but {
    .upopupnrbut {
      padding: 24rpx 32rpx;
      background-color: #3476fe;
      border-radius: 10rpx;
      color: #ffffff;
      display: inline-block;
      width: 90%;
      font-size: 30rpx;
    }
  }
}

.popupShow {
  overflow: hidden;
  position: fixed;
  height: 100%;
  width: 100%;
}
</style>